[id].vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <!-- 页面头部 -->
  3. <HomePageHead></HomePageHead>
  4. <!-- 导航栏 -->
  5. <HomePageNavigation></HomePageNavigation>
  6. <!-- 列表页广告一 -->
  7. <HomeTopTen :imgurl="adImg1" v-if="adImg1"></HomeTopTen>
  8. <!-- 资讯列表 -->
  9. <main class="index_main">
  10. <!-- 面包屑导航 -->
  11. <div class="breadcrumb">
  12. <div class="inner">
  13. <span class="location">当前位置:</span>
  14. <el-breadcrumb :separator-icon="ArrowRight">
  15. <el-breadcrumb-item>
  16. <NuxtLink to="/">首页</NuxtLink>
  17. </el-breadcrumb-item>
  18. <el-breadcrumb-item v-if="parent_name != ''">
  19. <NuxtLink :to="`/${targetSegment}/index.html`"> {{ parent_name }}</NuxtLink>
  20. </el-breadcrumb-item>
  21. <el-breadcrumb-item>{{ routeNewsTtitle }}</el-breadcrumb-item>
  22. </el-breadcrumb>
  23. </div>
  24. </div>
  25. <section class="index_2 clearfix">
  26. <img class="index_2_img" :src="img_one" :title="newsDetail.title" :alt="newsDetail.title">
  27. <div class="index_2_right">
  28. <h4 class="index_2_h4">{{ newsDetail.title }}</h4>
  29. <div class="index_2_ul clearfix">
  30. <div class="index_2_li clearfix">
  31. <label class="index_2_li_label">企业名称</label>
  32. <span class="index_2_li_text">{{ newsDetail.business_name }}</span>
  33. </div>
  34. <div class="index_2_li clearfix">
  35. <label class="index_2_li_label">联 系 人</label>
  36. <span class="index_2_li_text">{{ newsDetail.content_person }}</span>
  37. </div>
  38. <div class="index_2_li clearfix">
  39. <label class="index_2_li_label">电 &nbsp;&nbsp;&nbsp;&nbsp; 话</label>
  40. <span class="index_2_li_text">{{ newsDetail.telephone }}</span>
  41. </div>
  42. <div class="index_2_li clearfix">
  43. <label class="index_2_li_label">手 &nbsp;&nbsp;&nbsp;&nbsp; 机</label>
  44. <span class="index_2_li_text">{{ newsDetail.mobile }}</span>
  45. </div>
  46. <div class="index_2_li clearfix">
  47. <label class="index_2_li_label">传 &nbsp;&nbsp;&nbsp;&nbsp; 真</label>
  48. <span class="index_2_li_text">{{ newsDetail.fax }}</span>
  49. </div>
  50. <div class="index_2_li clearfix">
  51. <label class="index_2_li_label">邮 &nbsp;&nbsp;&nbsp;&nbsp; 箱</label>
  52. <span class="index_2_li_text">{{ newsDetail.email }}</span>
  53. </div>
  54. <div class="index_2_li clearfix">
  55. <label class="index_2_li_label">邮 &nbsp;&nbsp;&nbsp;&nbsp; 编</label>
  56. <span class="index_2_li_text">{{ newsDetail.post_code }}</span>
  57. </div>
  58. <div class="index_2_li clearfix">
  59. <label class="index_2_li_label">地 &nbsp;&nbsp;&nbsp;&nbsp; 址</label>
  60. <span class="index_2_li_text">{{ newsDetail.address }}</span>
  61. </div>
  62. </div>
  63. </div>
  64. </section>
  65. <section class="index_3 clearfix">
  66. <div class="show_head_box clearfix">
  67. <span class="show_head_a show_head_a_only">项目介绍</span>
  68. </div>
  69. <article class="show_article" v-html="newsDetail.introduce">
  70. </article>
  71. </section>
  72. <section class="index_4 clearfix">
  73. <div class="show_head_box_2 clearfix">
  74. <span class="show_head_a_2 show_head_a_only_2">加盟详情</span>
  75. </div>
  76. <article class="show_article_2" v-html="newsDetail.franchise_details">
  77. </article>
  78. </section>
  79. <section class="index_4 clearfix">
  80. <div class="show_head_box_3 clearfix">
  81. <span class="show_head_a_3 show_head_a_only_3">图片展示</span>
  82. </div>
  83. <div class="img_ul_1 clearfix">
  84. <div class="img_li_1" title="" v-for="(item, index) in imgList" :key="index">
  85. <img class="img_li_1_img" :src="item" :title="newsDetail.title" :alt="newsDetail.title">
  86. </div>
  87. </div>
  88. </section>
  89. <section class="index_5 clearfix">
  90. <div class="index_2_head clearfix">
  91. <span class="index_2_head_a index_2_head_a_only" title="">精品项目推荐</span>
  92. </div>
  93. <div class="categ_ul_img_1">
  94. <div class="categ_li_img_1" v-for="(item, index) in recommend" :key="index">
  95. <a class="categ_li_img_1_a" :href="getLinkPathDetail(item)" :title="item.title">
  96. <img class="categ_li_img_1_img" :src="item.imgurl" :title="item.title" :alt="item.title">
  97. <div class="categ_li_img_1_dot2 dot2">
  98. {{ item.title }}
  99. </div>
  100. </a>
  101. </div>
  102. </div>
  103. </section>
  104. </main>
  105. <HomeTopTen :imgurl="adImg2" v-if="adImg2"></HomeTopTen>
  106. <!-- 页面底部 -->
  107. <HomeFoot1></HomeFoot1>
  108. </template>
  109. <script setup>
  110. //1.页面依赖 start ---------------------------------------->
  111. import { onMounted } from 'vue'
  112. import { ElBreadcrumb, ElBreadcrumbItem } from 'element-plus'
  113. import { ArrowRight } from '@element-plus/icons-vue'
  114. //1.页面依赖 end ---------------------------------------->
  115. //2.页面路径 start ---------------------------------------->
  116. const route = useRoute();
  117. const articleId = parseInt(route.params.id);
  118. const targetSegment = getRoutePath(1);
  119. const targetSegment1 = getRoutePath(2);
  120. const parent_name = ref("");
  121. const parent_id = ref("");
  122. //通过导航路径反向查询导航id
  123. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  124. method: 'GET',
  125. query: {
  126. 'pinyin': targetSegment,
  127. },
  128. });
  129. if (getRouteId.code == 200) {
  130. parent_name.value = getRouteId.data.alias;
  131. parent_id.value = getRouteId.data.category_id;
  132. } else {
  133. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  134. console.log("错误位置:通过url路径查询导航池id")
  135. console.log("后端错误反馈:", getRouteId.message)
  136. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  137. }
  138. //2.页面路径 end ---------------------------------------->
  139. //3.面包屑 start ---------------------------------------->
  140. const routLevelTitle = ref("");
  141. const routLevelId = ref("");
  142. const getRouteId1 = await requestDataPromise('/web/getWebsiteRoute', {
  143. method: 'GET',
  144. query: {
  145. 'pinyin': targetSegment1,
  146. },
  147. });
  148. if (getRouteId1.code == 200) {
  149. routLevelTitle.value = getRouteId1.data.alias;
  150. routLevelId.value = getRouteId1.data.category_id;
  151. } else {
  152. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  153. console.log("错误位置:通过url路径查询导航池id")
  154. console.log("后端错误反馈:", getRouteId.message)
  155. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  156. }
  157. //3.面包屑 end ---------------------------------------->
  158. //4.新闻详情 start ---------------------------------------->
  159. //4.1 资讯详情
  160. const newsDetail = ref({})
  161. const routeNewsTtitle = ref("");
  162. //4.2 发布日期
  163. const time = ref("");
  164. // 图片列表
  165. const imgList = ref([]);
  166. const img_one = ref("");
  167. //4.3 获取详情
  168. let seoTitle;
  169. let seoDescription;
  170. let seoKeywords;
  171. async function getPageData() {
  172. const mkdata = await requestDataPromise('/web/getWebsiteProjectInfo', {
  173. method: 'GET',
  174. query: {
  175. 'id': articleId
  176. },
  177. });
  178. if (mkdata.code == 200) {
  179. //获取内容
  180. newsDetail.value = mkdata.data;
  181. //获取发布时间
  182. time.value = newsDetail.value.updated_at.split(' ')[0];
  183. //修正标题长度
  184. if (newsDetail.value.title.length >= 20) {
  185. routeNewsTtitle.value = newsDetail.value.title.substr(0, 20) + "...";
  186. } else {
  187. routeNewsTtitle.value = newsDetail.value.title
  188. }
  189. // 图片列表
  190. imgList.value = JSON.parse(mkdata.data.imgurl);
  191. img_one.value = imgList.value[0];
  192. seoTitle = newsDetail.value.title;
  193. seoDescription = newsDetail.value.description;
  194. seoKeywords = newsDetail.value.keyword;
  195. } else {
  196. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  197. console.log("错误位置:获取详情内容")
  198. console.log("后端错误反馈:", mkdata.message)
  199. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  200. }
  201. }
  202. getPageData();
  203. //4.新闻详情 end ---------------------------------------->
  204. // 推荐
  205. let getJson1 = [
  206. { "level": "1,12,0" },
  207. ]
  208. let jsonString1 = JSON.stringify(getJson1);
  209. getPageHotData(jsonString1);
  210. // 获取推荐数据
  211. let recommend = ref([]);
  212. async function getPageHotData(jsonString1) {
  213. const mkdata = await requestDataPromise('/web/getWebsiteProject', {
  214. method: 'GET',
  215. query: {
  216. 'id': jsonString1
  217. },
  218. });
  219. console.log('mkdata_HotData', mkdata.data)
  220. if (mkdata.code == 200) {
  221. if (mkdata.data.length > 0) {
  222. recommend.value = mkdata.data[0].img_num;
  223. }
  224. } else {
  225. ElMessage.error(mkdata.message)
  226. }
  227. }
  228. //5.设置seo信息 start---------------------------------------->
  229. const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
  230. method: 'GET',
  231. query: {
  232. 'catid': parent_id.value
  233. },
  234. });
  235. if (setData.code == 200) {
  236. let seoSuffix = setData.data.suffix;
  237. let seoName = setData.data.website_name;
  238. useSeoMeta({
  239. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  240. meta: [
  241. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  242. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
  243. ]
  244. });
  245. } else {
  246. console.log("设置频道页SEO出错!", setData.message)
  247. }
  248. //5.设置seo信息 end---------------------------------------->
  249. //6.广告 start ---------------------------------------->
  250. let adImg1 = ref([]);
  251. let adImg2 = ref([]);
  252. onMounted(async () => {
  253. const { $webUrl, $CwebUrl } = useNuxtApp();
  254. //广告1
  255. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nzgxw_detail_0001`
  256. const responseAd1 = await fetch(url, {
  257. headers: {
  258. 'Content-Type': 'application/json',
  259. 'Userurl': $CwebUrl,
  260. 'Origin': $CwebUrl
  261. }
  262. });
  263. const resultAd1 = await responseAd1.json();
  264. adImg1.value = resultAd1.data[0];
  265. //广告2
  266. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nzgxw_detail_0002`
  267. const responseAd2 = await fetch(url2, {
  268. headers: {
  269. 'Content-Type': 'application/json',
  270. 'Userurl': $CwebUrl,
  271. 'Origin': $CwebUrl
  272. }
  273. });
  274. const resultAd2 = await responseAd2.json();
  275. adImg2.value = resultAd2.data[0];
  276. })
  277. //6.广告 end ---------------------------------------->
  278. //8.页面图片放大 start---------------------------------------->
  279. const previewVisible = ref(false)
  280. const selectedImage = ref(' ')
  281. const openPreview = (event) => {
  282. if (event.target.tagName === 'IMG') {
  283. selectedImage.value = event.target.src;
  284. previewVisible.value = true;
  285. }
  286. }
  287. const closePreview = () => {
  288. previewVisible.value = false;
  289. }
  290. //8.页面图片放大 end---------------------------------------->
  291. </script>
  292. <style lang="less" scoped>
  293. @import url('@/assets/css/project/detail.less');
  294. </style>